#include <assert.h>
#include <getopt.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include "types.h"
using namespace std;

void cmdLine(int argc, char *argv[], _DOUBLE_& T, int& n, int& tx, int& ty, int& do_stats, int& plot_freq, int& prefer_l1){
/// Command line arguments
 // Default value of the domain sizes
 static struct option long_options[] = {
        {"n", required_argument, 0, 'n'},
        {"tx", required_argument, 0, 'x'},
        {"ty", required_argument, 0, 'y'},
        {"tfinal", required_argument, 0, 't'},
        {"stats", no_argument, 0, 's'},
        {"plot", required_argument, 0, 'p'},
        {"l1", no_argument, 0, 'l'},
 };
    // Process command line arguments
 int ac;
 for(ac=1;ac<argc;ac++) {
    int c;
    while ((c=getopt_long(argc,argv,"n:x:y:t:sp:l",long_options,NULL)) != -1){
        switch (c) {

	    // Size of the computational box
            case 'n':
                n = atoi(optarg);
                break;

            // Length of simulation, in simulated time units
            case 't':
                T = atof(optarg);
                break;

	    // X thread block geometry
            case 'x':
                tx = atoi(optarg);
                break;

	    // Y thread block geometry
            case 'y':
                ty = atoi(optarg);
                break;


	    // Print various statistics
            case 's':
                do_stats = 1;
                break;

	    // Plot the excitation variable, with a given frequency
            case 'p':
                plot_freq = atoi(optarg);
                break;

	    // Favor L1 cache (48 KB), else favor Shared memory
            case 'l':
                prefer_l1 = 1;
                break;

	    // Error
            default:
                printf("Usage: apf [-n <domain size>] [-t <final time >]\n\t [-s print statistics ] [-p <plot frequency>]\n\t[-tx <x thread block geometry> [-ty <y thread block geometry] [-l  <prefer l1>]\n");
                exit(-1);
            }
    }
 }
}
